package register

import (
	"encoding/json"
	"fmt"
	"io/ioutil"
	. "myTaxServer/configs"
	. "myTaxServer/src/structs"
	"net/http"
)

func GetSessiocKey(code string)  UnionIdBody{
	strings := Code2Session + "appid=" + APPID + "&secret=" + SECRET +"&js_code=" + code + "&grant_type=authorization_code";
	client := &http.Client{}
	resp, err := client.Get(strings)//get请求
	defer resp.Body.Close()
	body, err := ioutil.ReadAll(resp.Body)//body是返回的数据
	if err != nil {//错误处理
		fmt.Println(err)
	}
	var strrr UnionIdBody; //这里是转化成结构体的
	err = json.Unmarshal(body, &strrr);
	if err != nil {
		fmt.Println("error:",err);
	}
	return strrr
}
